<%@ Control Language="VB" AutoEventWireup="false" CodeFile="CustomDropDownJSON.ascx.vb"
    Inherits="UserCuntrols_CustomDropDownJSON" %>
<input type="hidden" id="DropValue" value="" />
<asp:TextBox ID="txtDropdown" ReadOnly="true" runat="server" CssClass="dropdownText"
    Text=" -- Select -- "></asp:TextBox>
<asp:Image ID="imgDropdown" CssClass="dropdownarrow" runat="server" ImageUrl="~/images/btnDropdown.gif"
    Style="margin-top:-5px; margin-left: -5px; cursor: pointer;" ImageAlign="Top" />
<asp:Panel HorizontalAlign="Left" ID="tx_div" runat="server" CssClass="dropdown"
    Style="display: none; width: 500px; position: absolute; border: 1px solid #CCCCCC;
    z-index: 999;">
    <asp:Literal ID="litDropDownContent" runat="server"></asp:Literal>
</asp:Panel>

<script language="javascript" type="text/javascript">
        OpenSubMenu = function(oBj){
            $("s_"+oBj.id).style.display = "";
            $("d_main").style.display = "none";
            SelectMenu(oBj);
        };
        OpenMenu = function(e){
            if (!e) var e = window.event;
            var target = e.target != null ? e.target : e.srcElement;
            
            $("<%=tx_div.ClientID %>").style.display = "";
            if(!window.event){
                $("<%=tx_div.ClientID %>").style.left = (target.offsetLeft - 450) + "px";
                $("<%=tx_div.ClientID %>").style.top = (target.offsetTop + 30)+"px";
            }
            else{
                $("<%=tx_div.ClientID %>").style.right = (target.offsetLeft - 192)+"px";
                if(document.IsSearched){
                    $("<%=tx_div.ClientID %>").style.top = (target.offsetTop + 180)+"px";
                }
                else{
                    $("<%=tx_div.ClientID %>").style.top = (target.offsetTop + 287)+"px";
                }
                
            }
        };
        CloseMenu = function(e){
            if (!e) var e = window.event;
            var target = e.target != null ? e.target : e.srcElement;
            
            if(target.className != "dropdownarrow" && target.className != "dropmenuitem")
               $("<%=tx_div.ClientID %>").style.display = "none";
        };
        SelectMenu = function(oBj){
            $("<%=txtDropdown.ClientID %>").value = (oBj.textContent)?oBj.textContent:oBj.innerText;
            $("DropValue").value = $("<%=txtDropdown.ClientID %>").value
        };
        BackMenu = function(){
            var aDiv = document.getElementsByTagName("div")
            for(i=0;i<aDiv.length;i++){
                if(aDiv[i].className == "submenuitem"){
                    aDiv[i].style.display = "none";
                }
            }
            $("d_main").style.display = "";
            $("DropValue").value = ""
        };
        document.onclick = CloseMenu;
        //$("<%=tx_div.ClientID %>").onmouseout = CloseMenu;
        //$("<%=tx_div.ClientID %>").onmouseover = OpenMenu;
        $("<%=imgDropdown.ClientID %>").onclick = OpenMenu;
</script>

